﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using FlickrMe.Config;
using FlickrMe.registry;

namespace FlickrMe.Config
{

    /*
     * A ConfigManager that uses the windows registry for reading/writing config
     * Information.
     */
    class RegistryBasedConfigManager : ConfigManager
    {

        override public FlickrConfig getConfig()
        {
            FlickrConfig c = new FlickrConfig();

            c.ApiKey = getApiKey();
            c.SharedSecret = getSharedSecret();
            c.AuthToken = getAuthToken();
            
            return c;
        }

        private String getApiKey()
        {
            return FlickrRegistryManager.getApiKey();
        }

        private String getSharedSecret()
        {
            return FlickrRegistryManager.getSharedKey();
        }

        private String getAuthToken()
        {
            return FlickrRegistryManager.getAuthKey();
        }

      
        override public void saveConfig(FlickrConfig config)
        {
            FlickrConfig fConfig = (FlickrConfig)config;
            FlickrRegistryManager.setAuthKey(fConfig.AuthToken);
        }
    }

    
}
